package com.pucheng.bracelet.ui.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.pucheng.bracelet.R;
import com.pucheng.bracelet.data.bean.BarChartBean;

import java.util.List;

public class TrendBarcharView extends LinearLayout {

    private TextView tvTrendTitle;
    private MyBarChart barChart;


    public TrendBarcharView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public TrendBarcharView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context);
    }

    public TrendBarcharView(Context context) {
        super(context);
        init(context);
    }

    public TrendBarcharView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        init(context);
    }

    private void init(Context context) {
        View view = inflate(context, R.layout.layout_trend_barchart, this);
        tvTrendTitle = view.findViewById(R.id.tv_trend_title);
        barChart = view.findViewById(R.id.bar_char);
    }

    public void showBarChart(final List<BarChartBean> dateValueList, int color) {
        barChart.showBarChart(dateValueList,color);
    }

    public void setTitle(String title){
        if (tvTrendTitle != null){
            tvTrendTitle.setText(title);
        }
    }


}
